<template>
<div>
    <h2 style="text-align: center;">个人资产信息</h2>
    <table class="table table-bordered" border="1">
        <tr>
            <td>登录名称</td>
            <td>
                {{ info.UL_Name }}
            </td>
        </tr>

        <tr>
            <td>投资总额</td>
            <td>
                {{ info.SUI_Money }}
            </td>
        </tr>

        <tr>
            <td>理财总额</td>
            <td>
                {{ SUF_Money }}
            </td>
        </tr>

        <tr>
            <td>借款总额</td>
            <td>
                {{ SUB_Money }}
            </td>
        </tr>
    </table>
</div>
</template>

<script setup lang="ts">
import { useUserStore } from '../../store/index.ts';
import axios from 'axios';
import {ref,onMounted} from 'vue';

const userStore=useUserStore();

//创建响应式数据
const info=ref({
    UL_Name:"",
    SUI_Money:0,
})
const SUF_Money=ref(0)
const SUB_Money=ref(0)


onMounted(()=>{
    LoadData()
    LoadData2()
    LoadData3()
})

const LoadData=()=>{
    axios.get("https://localhost:44321/api/Users/GetUserIncomeInfo",
        {
            params:{
                Uid:userStore.Uid
            }
        }
    )
    .then(res=>{
        console.log(res.data)
        info.value=res.data[0]
    })
    .catch(error=>{
        console.log(error);
    })
}

const LoadData2=()=>{
    axios.get("https://localhost:44321/api/Users/GetUserFinanInfo",
        {
            params:{
                Uid:userStore.Uid
            }
        }
    )
    .then(res=>{
        console.log(res.data)
        SUF_Money.value=res.data[0].SUF_Money
    })
    .catch(error=>{
        console.log(error);
    })
}

const LoadData3=()=>{
    axios.get("https://localhost:44321/api/Users/GetUserBorrowInfo",
        {
            params:{
                Uid:userStore.Uid
            }
        }
    )
    .then(res=>{
        console.log(res.data)
        SUB_Money.value=res.data[0].SUB_Money
    })
    .catch(error=>{
        console.log(error);
    })
}
</script>
